<title>Sites management</title>
<?php
	require_once('config.php');
	require_once('db.php');
	$link = connectdb($servername,$dbname,$dbusername,$dbpassword);
 	if(!$link)
 	{
 		die("Could not connect to MySQL");
 	}
 	$query="SELECT * FROM sites;";
 	$rt=mysql_query($query);  
 	if (!$rt)
 	{
 		echo mysql_error();
 		return;
 	}
?>

<div align="center"><h1>Site Management</h1></div>
<table width="60%" style="margin-left: 20%" border="1" cellspacing="1" cellpadding="0">
<tr>
<td>
	<table width="100%" border="0" cellspacing="0" cellpadding="10px">
		<tr>
			<td align="center"><strong>ID</strong></td>
			<td align="center"><strong>Hostname</strong></td>
			<td align="center"><strong>Status</strong></td>
			<td align="center"><strong>Update</strong></td>
			<td align="center"><strong>Delete</strong></td>
		</tr>
		<?php
			while($rows=mysql_fetch_array($rt)){				
		?>
		<tr>
			<?php
				$id=$rows['id'];				
			 ?>			 
			<td align="center"><?php echo $id;?></td>	
			<td align="center"><?php echo $rows["hostname"]; ?></td>
			<td align="center">
			<?php 
			if(trim($rows["pause"])=== "0") 
				echo "Enabled";
			else
				echo "Disabled"; 
			?></td>
			<td align="center"><a href="updatesite.php?id=<?php echo $id; ?>">detail - update</a></td>
			<td align="center"><a href="deletesite.php?id=<?php echo $id; ?>">delete</a></td>
		</tr>
		<?php
			}
		?>
		<tr>
			<td align="right" colspan="5"><a href="addsite.php">Add new</a></td>
		</tr>		
	</table>
</td>
</tr>
</table>
<div align="center"><?php if(isset($_GET['message'])) echo $_GET['message'];?></div><br />
<div align="center"><a href="index.php">Back to Main Menu</a></div>
<?php
	close($link);
?>
<?php
